package com.songlin.testv2ex.ui.fragment;

import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.songlin.testv2ex.R;

/**
 * Created by 松林 on 2015/10/2.
 */
public class TestFragment extends Fragment {
    private static final String TAG = "TestFragment";
    private String hello;// = "hello android";
    private String defaultHello = "default value";

    public static TestFragment newInstance(String s) {
        TestFragment newFragment = new TestFragment();
        Bundle bundle = new Bundle();
        bundle.putString("hello", s);
        newFragment.setArguments(bundle);
        //bundle还可以在每个标签里传送数据

        return newFragment;
    }

    @Override
    public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Log.d(TAG,"Test  - - TestFragment");
        Bundle args = getArguments();
        hello =   (args != null)  ?  (args.getString("hello"))  :  defaultHello;

        ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_test,container,false);
        TextView view_hello = (TextView) rootView.findViewById(R.id.tv);
        view_hello.setText(hello);
        view_hello.setTypeface(Typeface.MONOSPACE);
        return rootView;
    }

}